package com.neusoft.chenhanhua.ChineseChess;

public class Xing {
 public boolean xing(int x1,int y1,int x2,int y2, int i,int [] xs,int [] ys){
	 if (i<16) {
			if (y2<6 && ((y2-y1==2 && x2-x1==2) || (y1-y2==2 && x1-x2==2) || (y2-y1==2 && x1-x2==2) || (y1-y2==2 && x2-x1==2)) ) {
				boolean zg=zhong(x1, y1, x2, y2, i, xs, ys);
				
				return zg;
			} 
		}else {
			if (y2>5  && ((y2-y1==2 && x2-x1==2) || (y1-y2==2 && x1-x2==2) || (y2-y1==2 && x1-x2==2) || (y1-y2==2 && x2-x1==2)) ) {
				boolean qr=zhong(x1, y1, x2, y2, i, xs, ys);
				return qr;
			} 
		}
		return false;
 }
         /*
          * @这个是判断相中间是否有棋子
          */
     public boolean zhong(int x1,int y1,int x2,int y2, int i,int [] xs,int [] ys) {
    	 for (int j = 0; j < ys.length; j++) {
				//左下方，不通
				if ((xs[j]==x1+1&&ys[j]==y1+1&&y2==y1+2&&x2==x1+2)) {
					return false;
				}
				//左上方，不通
				if ((xs[j]==x1+1&&ys[j]==y1-1&&y2==y1-2&&x2==x1+2)) {
					return false;
				}
				//右上方，不通
				if ((xs[j]==x1-1&&ys[j]==y1-1&&y2==y1-2&&x2==x1-2)) {
					return false;
				}
				//右下方，不通
				if ((xs[j]==x1-1&&ys[j]==y1+1&&y2==y1+2&&x2==x1-2)) {
					return false;
				}
				//判断有棋子就不能占
				if (x2==xs[j]&&y2==ys[j]) {
					return false;
				}
			}
    	 return true;
    	 
     }
}
